package com.heima.user.controller.v1;

import com.heima.common.dtos.PageResult;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDTO;
import com.heima.model.user.dtos.UserAuthDto;
import com.heima.model.user.dtos.UserAuthListRequestParamDTO;
import com.heima.user.service.ApUserAuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Fuqiang
 * @since :2023-03-24
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/auth")
public class AuthController {

    @Autowired
    ApUserAuthService apUserAuthService;

    /**
     * 根据用户状态分页查询App端用户认证列表
     *
     * @param authDto
     * @return
     */
    @PostMapping("/list")
    public PageResult<UserAuthDto> list(@RequestBody UserAuthListRequestParamDTO authDto) {

        return apUserAuthService.findByPage(authDto);
    }

    /**
     * 用户认证信息审核不通过
     *
     * @param dto
     * @return
     */
    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody @Validated AuthDTO dto) {

        apUserAuthService.authFail(dto);
        return ResponseResult.ok();
    }

    /**
     * 用户认证信息审核通过
     *
     * @param dto
     * @return
     */
    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody @Validated AuthDTO dto) {

        apUserAuthService.authPass(dto);
        return ResponseResult.ok();
    }
}
